package com.xtayfjpk.zookeeper.test.master_workers.watcher;

import org.apache.zookeeper.WatchedEvent;
import org.apache.zookeeper.Watcher;
import org.apache.zookeeper.Watcher.Event.EventType;

import com.xtayfjpk.zookeeper.test.master_workers.Client;

public class TaskStatusWatcher implements Watcher {
	private Client client;
	
	public TaskStatusWatcher(Client client) {
		this.client = client;
	}

	@Override
	public void process(WatchedEvent event) {
		if(event.getType() == EventType.NodeCreated) {
			assert event.getPath().contains("/status/task-");
			assert client.getCtxMap().containsKey(event.getPath());
			
			client.getTaskResult(event.getPath());
		}

	}

}
